
  @include('public.page_styles')
  <link rel="stylesheet" href="{{ asset("/AdminLTE/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css") }}">

</head>


<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  @include('public.top')
  <!-- Left side column. contains the logo and sidebar -->
  @include('public.sidebar')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
          {{ trans('message.equipment') }}
        <small>{{ trans('message.list') }}</small>
      </h1>
      <ol class="breadcrumb">
        <li><a ><i class="fa fa-dashboard"></i> {{ trans('message.home') }}</a></li>
        <li><a >{{ trans('message.serviceManage') }}</a></li>
        <li class="active"> {{ trans('message.equipmentManage') }}</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title"></h3>
                @if(in_array(getOptionId('新增'),$optionArr))
                    <a href="{{ url('equipment/create') }}" class="btn btn-sm btn-success">
                        <i class="fa fa-save"></i>&nbsp;&nbsp;{{ trans('message.add') }}
                    </a>
                @endif

              <div class="pull-right">
                <div class="btn-group pull-right" style="margin-right: 10px">
                  <span>
                  <a href="javascript:void(0);"class="btn btn-sm btn-primary grid-refresh" onclick="refresh()"><i class="fa fa-refresh"></i> {{ trans('message.refresh') }} </a>
                  </span>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        {{--<th>ID</th>--}}
                        <th>设备编号</th>
                        <th>设备名称</th>
                        <th>所属网点</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>更新时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if($bankShopEp)
                        @foreach($bankShopEp as $equipment)
                            <tr>
                                {{--<td>{{ $equipment->id }}</td>--}}
                                <td>{{ $equipment->e_code }}</td>
                                <td>{{ $equipment->e_name }}</td>
                                <td>{{ $equipment->shopName }}</td>
                                <td><a href="javascript:void(0);" data-id="{{ $equipment->id }}" data-state="{{ $equipment->state }}" class="changeS">{{state_config('bank_show',$equipment->state) }}</a></td>
                                <td>{{ $equipment->created_at }}</td>
                                <td>{{ $equipment->updated_at }}</td>
                                <td>
                                    @if(count(DB::table('order')->where('e_code',$equipment->e_code)->get()))
                                        <a href="{{ url('equipment/info/order/'.$equipment->id) }}">查看订单</a>　
                                    @else
                                        @if(in_array(getOptionId('编辑'),$optionArr))
                                            <a href="{{ url('equipment/edit') }}/{{ $equipment->id }}"><i class="fa fa-edit"></i></a>　
                                        @endif
                                        @if(in_array(getOptionId('删除'),$optionArr))
                                            <a  href="javascript:void(0);" data-id="{{ $equipment->id }}" class="u_del"><i class="fa fa-trash"></i></a>
                                        @endif
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!-- /.content-wrapper -->
  @include('public.bottom')

  <!-- Control Sidebar -->
  {{--@include('public.aside')--}}
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
@include('public.javascript')
<script src="{{ asset ("/AdminLTE/bower_components/datatables.net/js/jquery.dataTables.min.js") }}" type="text/javascript"></script>
<script src="{{ asset ("/AdminLTE/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js") }}" type="text/javascript"></script>
<script src="{{ asset ("/AdminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js") }}" type="text/javascript"></script>
{{--<script src="{{ asset ("/AdminLTE/bower_components/fastclick/lib/fastclick.js") }}" type="text/javascript"></script>--}}
<script src="{{ asset ("/js/bootbox.js") }}" type="text/javascript"></script>

<!-- page script -->
<script>
  $(function(){
      bootbox.setDefaults({
          locale: "zh_CN",
      });

      $.ajaxSetup({
          headers: {
              'X-CSRF-TOKEN': '{{ csrf_token() }}'
          }
      });


      $('#example1').dataTable({
          "language": {
              "url":"{{ asset ("/AdminLTE/bower_components/datatables.net/chinese.json") }}"
          },
          "aaSorting": [[ 4, "desc" ]],//默认第几个排序
          "bStateSave": true,//状态保存
          "aoColumnDefs": [
              //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
              {"orderable":false,"aTargets":[0,1,2,3,6]}// 制定列不参与排序
          ]
      });
      $('.table-sort tbody').on( 'click', 'tr', function () {
          if ( $(this).hasClass('selected') ) {
              $(this).removeClass('selected');
          }
          else {
              table.$('tr.selected').removeClass('selected');
              $(this).addClass('selected');
          }
      });


      @if(session()->has('success'))
         alertMess("{{session()->get('success')}}");
      @endif

      $('.changeS').click(function () {
          var sid = $(this).data('id');
          var state = $(this).data('state');
          var txt ='';
          if(state == 1 ){
              txt ='停用';
              state = 2;
          }else{
              txt = '启用';
              state = 1;
          }

          bootbox.confirm('确定要'+txt+'吗？', function(result) {
              if(result){
                  $.ajax({
                      type: "post",
                      url: "{{url('equipment/list/state')}}",
                      data: {
                          id:sid,
                          state:state,
                      },
                      dataType: "json",
                      success: function (response){
                          console.log(response);
                          if(response == 1) {
                              alertMess("修改状态成功");
                          }else if(response == -3){
                              alertMess('该设备有未完成订单，修改状态失败');
                          }else{
                              alertMess('参数错误，修改状态失败');
                          }
                      }
                  });
              }
          });

      });

      $('.u_del').click(function(e){
        var id=$(this).data('id');
          bootbox.confirm('确定要删除吗？', function(result) {
              if(result){
                  $.ajax({
                      url: '{{url('equipment/list/del')}}',
                      type: 'get',
                      data : {id : id},
                      success: function (response) {
                          console.log(response);
                          if (response == 1) {
                              alertMess("删除成功");
                          }else{
                              alertMess("删除失败");
                          }
                      },
                  });
              }
          });

    });
























  });

</script>
</body>
</html>
